<?php

/**
 * This is the model class for table "supplier_evaluation".
 *
 * The followings are the available columns in table 'supplier_evaluation':
 * @property string $id
 * @property string $supplier_code
 * @property string $evaluation_number
 * @property integer $evaluation_number_seq
 * @property string $revision_number
 * @property string $date_from
 * @property string $date_thru
 * @property string $remarks
 * @property string $note
 * @property string $ranking
 * @property string $total_mark
 * @property string $evaluation_date
 */
class SupplierEvaluation extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SupplierEvaluation the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'supplier_evaluation';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('evaluation_number_seq', 'numerical', 'integerOnly'=>true),
			array('total_mark', 'length', 'max'=>18),
			array('supplier_code, evaluation_number, revision_number, date_from, date_thru, remarks, note, ranking, evaluation_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, supplier_code, evaluation_number, evaluation_number_seq, revision_number, date_from, date_thru, remarks, note, ranking, total_mark, evaluation_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'supplier_code' => 'Supplier Code',
			'evaluation_number' => 'Evaluation Number',
			'evaluation_number_seq' => 'Evaluation Number Seq',
			'revision_number' => 'Revision Number',
			'date_from' => 'Date From',
			'date_thru' => 'Date To',
			'remarks' => 'Remarks',
			'note' => 'Note',
			'ranking' => 'Ranking',
			'total_mark' => 'Total Mark',
			'evaluation_date' => 'Evaluation Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('supplier_code',$this->supplier_code,true);
		$criteria->compare('evaluation_number',$this->evaluation_number,true);
		$criteria->compare('evaluation_number_seq',$this->evaluation_number_seq);
		$criteria->compare('revision_number',$this->revision_number,true);
		$criteria->compare('date_from',$this->date_from,true);
		$criteria->compare('date_thru',$this->date_thru,true);
		$criteria->compare('remarks',$this->remarks,true);
		$criteria->compare('note',$this->note,true);
		$criteria->compare('ranking',$this->ranking,true);
		$criteria->compare('total_mark',$this->total_mark,true);
		$criteria->compare('evaluation_date',$this->evaluation_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}